The Trick to Teach Anonymous Functions to 11-Year-Olds

Steve Krouse
3 min readJul 27, 2016

--

Last week I was working with an 11-year-old student, Jenny, who was new to coding. After spending a few days in Scratch, she was now building a Flappy Bird-esque game in JavaScript using the WoofJS framework.

“Is this coding advanced?” Jenny asked.

Trying to reassure her, I pointed out some of the JavaScript features she was using through the WoofJS framework, “Sure it is. See here, you’re using Object-Oriented Programming, which is a high school Advanced Placement topic, and here you’re using complex Boolean algebra.”

Jenny smiled. She liked this game of me naming the concepts she was using with fancy technical terms.

“And here, I almost forgot. You’re using no less than 1, 2, 3…15 anonymous functions!”

I thought about that for a minute. This was Jenny’s second day programming in JavaScript and Woof. She’s 11. Who taught her how to use anonymous functions? It sure wasn’t me.

In computer science, a anonymous function is considered a fairly advanced topic. Many computer science majors in college don’t learn it until their upper-level courses, if at all. I wanted to check how well Jenny knew what she was talking about.

“Jenny, all of these things are called anonymous functions. Do you know what they do?”

Jenny looked at her code. “Um, I’m not sure. I just use them when I want something to happen.”

I laughed. It’s not a definition that would pass on a computer science exam, but it was a solid working definition that clearly allowed her to use them effectively.

Embrace the Mess

Learning a spoken language — be it English, Spanish or Chinese — is a messy process. At its best, learning a computer language is equally messy.

Imagine what it would’ve been like if you had to understand grammar — nouns, verbs, sentence structure, and punctuation — before you were allowed to speak your native language. That’s often what coding education looks like. First, let’s learn about coding — variables, if-statements, types — and then start coding after.

But that’s entirely backward. Learning a language, both spoken and computer, should first be a doing activity, and secondly an analytical activity. What this means is deliberately not teaching about concepts like anonymous functions before letting students loose to use them.

Will this result in students getting things wrong at first? You bet.

Will students get confused and frustrated? No doubt.

Will students be able to recite dictionary definitions? No chance.

But despite all this, learning the messy way — a common feature of project-based learning environments — is more effective and drastically more fun.

WoofJS

Unfortunately not every programming language lends itself to this hands-off approach to teaching. Most programming languages, including HTML, CSS and JavaScript, have syntax that make it incredibly difficult for students to figure out via trial-and-error.

That’s why I’m so excited about WoofJS, a JavaScript framework that enables students to learn JavaScript the messy way. In Woof, students are free to play with advanced programming concepts through trial-and-error, no pre-requisites required.

Instead of spending hours memorizing and googling new syntax, Woof provides a clear interface for students to learn through exploration and experimentation.

So the trick to teaching anonymous functions to 11-year-olds? Don’t. With Woof, they’ll figure it out themselves better anyway.

--

--

Steve Krouse

Enabling computational thinking by building tools for thought at futureofcoding.org. Co-creator of thecodingspace.com and woofjs.com